import { fileURLToPath } from 'node:url';
import { defineConfig } from 'vite';
import vuePlugin from '@vitejs/plugin-vue';
import vueJsxPlugin from '@vitejs/plugin-vue-jsx';
import UnoCSS from 'unocss/vite';
// import prettierPlugin from 'vite-plugin-prettier';

// https://vitejs.dev/config/
export default defineConfig(async () => {
  const vueJsx =
    (vueJsxPlugin as unknown as { default: any }).default || vueJsxPlugin;
  const vue = (vuePlugin as unknown as { default: any }).default || vuePlugin;

  return {
    base: './',
    plugins: [vue(), vueJsx(), UnoCSS()],
    resolve: {
      alias: [
        {
          find: ':',
          replacement: fileURLToPath(new URL('./src', import.meta.url)),
        },
      ],
    },
    server: {
      port: 3001,
    },
  };
});

